import java.util.Arrays;
import java.util.Random;

public class RandomIntegerGenerator {
    public static void main(String[] args) {
        // 生成100个随机浮点数
        double[] randomFloats = new double[100];
        Random random = new Random();
        for (int i = 0; i < 100; i++) {
            randomFloats[i] = random.nextDouble(); // 或使用 Math.random()
        }

        // 创建索引数组并与浮点数关联
        IndexedDouble[] indexedDoubles = new IndexedDouble[100];
        for (int i = 0; i < 100; i++) {
            indexedDoubles[i] = new IndexedDouble(randomFloats[i], i);
        }

        // 按浮点数大小排序索引数组
        Arrays.sort(indexedDoubles, (a, b) -> Double.compare(a.value, b.value));

        // 提取排序后的整数序列（0~99乱序）
        int[] result = new int[100];
        for (int i = 0; i < 100; i++) {
            result[i] = indexedDoubles[i].index;
        }

        // 输出结果
        System.out.println(Arrays.toString(result));
    }

    static class IndexedDouble {
        double value;
        int index;

        public IndexedDouble(double value, int index) {
            this.value = value;
            this.index = index;
        }
    }
}    